<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">


		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:userDept:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:userDept:remove')}]];
        var prefix = ctx + "system/userDept";
        var datas = [[${@dict.getType('sys_normal_disable')}]];
        var prefix1 = ctx + "system/role";
        var roleId=1;
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "用户部门",
                columns: [
                    {
                        field: 'userId',
                        title: '用户ID'
                    },
                    {
                        field: 'loginName',
                        title: '登录名称',
                        sortable: true
                    },
                    {
                        field: 'userName',
                        title: '用户名称'
                    },
                    {
                        field: 'dept.deptName',
                        title: '部门'
                    },
                    {
                        field: 'email',
                        title: '邮箱',
                        visible: false
                    },
                    {
                        field: 'phonenumber',
                        title: '手机'
                    },
                    {
                        field: 'status',
                        title: '状态',
                        align: 'center',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        sortable: true
                    },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="#" onclick="rule(\'' + row.roleId + '\')"><i class="fa fa-check-square-o"></i>数据权限</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        /*角色管理-分配数据权限*/
        function rule(roleId) {
            var url = prefix1 + '/rule/' + roleId;
            $.modal.open("分配数据权限", url);
        }
    </script>
</body>
</html>